import { type ResourceUtilizationParams } from '../apis';
import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, NOTICEDATE, INFO_SOURCE, PROVINCE, CITY, INDUSTRY_CATEGORY, BUSINESS_DATA, REGISTERED_CAPITAL } from '@/utils';

export function useTable() {
  const queryData = reactive<ResourceUtilizationParams>({
    pageNum: 1,
    pageSize: 15,
    type: 1,
    sortRule: 'noticeDate:desc'
  });

  const tableData = ref([]);

  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    { ...NOTICEDATE },
    { ...INFO_SOURCE('catalogueName') },
    {
      title: '认定批次',
      field: 'batch',
      width: 100,
      align: 'center',
      sortable: true,
      sortBy: 'batch'
    },
    {
      title: '发布单位',
      field: 'postAgency',
      width: 200, //因该表格列数少，不能铺满全屏，这里不传width让其自适应
      sortable: true,
      sortBy: 'postAgency'
    },
    { ...PROVINCE },
    { ...CITY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  return {
    queryData,
    tableData,
    columns
  };
}
